import 'package:htxd_flutter_mapbox_sdk/entity/point_entity.dart';

/// parent : ""
/// address : "莲花池东路118号"
/// distance : ""
/// pcode : "110000"
/// adcode : "110106"
/// pname : "北京市"
/// cityname : "北京市"
/// type : "交通设施服务;火车站;火车站"
/// typecode : "150200"
/// adname : "丰台区"
/// citycode : "010"
/// name : "北京西站"
/// location : "116.322056,39.894910"
/// id : "B000A83M61"

class SearchPoiEntity {
  SearchPoiEntity({
    String? parent,
    String? address,
    String? distance,
    String? pcode,
    String? adcode,
    String? pname,
    String? cityname,
    String? type,
    String? typecode,
    String? adname,
    String? citycode,
    String? name,
    String? location,
    String? id,
  }) {
    _parent = parent;
    _address = address;
    _distance = distance;
    _pcode = pcode;
    _adcode = adcode;
    _pname = pname;
    _cityname = cityname;
    _type = type;
    _typecode = typecode;
    _adname = adname;
    _citycode = citycode;
    _name = name;
    _location = location;
    _id = id;
  }

  SearchPoiEntity.fromJson(dynamic json) {
    _parent = json['parent'];
    _address = json['address'];
    _distance = json['distance'];
    _pcode = json['pcode'];
    _adcode = json['adcode'];
    _pname = json['pname'];
    _cityname = json['cityname'];
    _type = json['type'];
    _typecode = json['typecode'];
    _adname = json['adname'];
    _citycode = json['citycode'];
    _name = json['name'];
    _location = json['location'];
    _id = json['id'];
    var split = _location!.split(",");
    _pointEntity = PointEntity(
        longitude: double.parse(split[0]), latitude: double.parse(split[1]));
  }

  String? _parent;
  String? _address;
  String? _distance;
  String? _pcode;
  String? _adcode;
  String? _pname;
  String? _cityname;
  String? _type;
  String? _typecode;
  String? _adname;
  String? _citycode;
  String? _name;
  String? _location;
  String? _id;
  PointEntity? _pointEntity;

  SearchPoiEntity copyWith({
    String? parent,
    String? address,
    String? distance,
    String? pcode,
    String? adcode,
    String? pname,
    String? cityname,
    String? type,
    String? typecode,
    String? adname,
    String? citycode,
    String? name,
    String? location,
    String? id,
  }) =>
      SearchPoiEntity(
        parent: parent ?? _parent,
        address: address ?? _address,
        distance: distance ?? _distance,
        pcode: pcode ?? _pcode,
        adcode: adcode ?? _adcode,
        pname: pname ?? _pname,
        cityname: cityname ?? _cityname,
        type: type ?? _type,
        typecode: typecode ?? _typecode,
        adname: adname ?? _adname,
        citycode: citycode ?? _citycode,
        name: name ?? _name,
        location: location ?? _location,
        id: id ?? _id,
      );

  String? get parent => _parent;

  String? get address => _address;

  String? get distance => _distance;

  String? get pcode => _pcode;

  String? get adcode => _adcode;

  String? get pname => _pname;

  String? get cityname => _cityname;

  String? get type => _type;

  String? get typecode => _typecode;

  String? get adname => _adname;

  String? get citycode => _citycode;

  String? get name => _name;

  String? get location => _location;

  String? get id => _id;

  PointEntity? get pointEntity => _pointEntity;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['parent'] = _parent;
    map['address'] = _address;
    map['distance'] = _distance;
    map['pcode'] = _pcode;
    map['adcode'] = _adcode;
    map['pname'] = _pname;
    map['cityname'] = _cityname;
    map['type'] = _type;
    map['typecode'] = _typecode;
    map['adname'] = _adname;
    map['citycode'] = _citycode;
    map['name'] = _name;
    map['location'] = _location;
    map['id'] = _id;
    map['pointEntity'] = _pointEntity;
    return map;
  }
}
